/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.DAO;

import com.DAO.ConexaoPostgreSQL.ConnectionFactory;
import com.Model.Usuario;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author Fellipe
 */
public class UsuarioDAO {
    
    private Connection con = new ConnectionFactory().getConnection();
    private PreparedStatement pstm;
    
    public void create() {
        
    }
    
    public void read(String chave) {
        
        Usuario u = new Usuario();
        
        try {
            
            String sql = "SELECT * FROM usuario WHERE chaveusuario = ? AND ativo = ?";
            pstm = con.prepareStatement(sql);
            pstm.setString(1, chave);
            pstm.setString(2, "1");
            ResultSet rs = pstm.executeQuery();
            
            while(rs.next()) {
                //fazer as parada
            }
            
        } catch (SQLException ex) {
            System.out.println(ex);
        } finally {
            try {
                pstm.close();
                con.close();
            } catch (SQLException ex) {
                System.out.println("Não foi possivel terminar a conexão " + ex);
            }
        }
        
    }
    
    public void update() {
        
    }
    
    public void delete() {
        
    }
    
}
